package com.ruoyi.bigScreen;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.zzw.TCatalogue;
import com.ruoyi.common.core.domain.zzw.VO.TCatalogueTree;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.ITCatalogueService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 目录Controller
 * 
 * @author ruoyi
 * @date 2023-11-03
 */
@RestController
@RequestMapping("/screen/catalogue")
@Api(tags = "目录管理")
public class ScreenCatalogueController extends BaseController
{
    @Autowired
    private ITCatalogueService tCatalogueService;

    /**
     * 查询目录列表
     */
    @GetMapping("/list")
    @ApiOperation("查询目录列表")
    public List<TCatalogueTree> list(TCatalogue tCatalogue)
    {
        List<TCatalogueTree> list = tCatalogueService.selectTCatalogueList(tCatalogue);
        return list;
    }

    /**
     * 导出目录列表
     */
    @Log(title = "目录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出目录列表")
    public void export(HttpServletResponse response, TCatalogue tCatalogue)
    {
//        List<TCatalogue> list = tCatalogueService.selectTCatalogueList(tCatalogue);
//        ExcelUtil<TCatalogue> util = new ExcelUtil<TCatalogue>(TCatalogue.class);
//        util.exportExcel(response, list, "目录数据");
    }

    /**
     * 获取目录详细信息
     */
    @GetMapping(value = "/{cCatalogueId}")
    @ApiOperation("获取目录详细信息")
    public AjaxResult getInfo(@PathVariable("cCatalogueId") Long cCatalogueId)
    {
        return success(tCatalogueService.selectTCatalogueByCCatalogueId(cCatalogueId));
    }

    /**
     * 新增目录
     */
    @Log(title = "目录", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增目录")
    public AjaxResult add(@RequestBody TCatalogue tCatalogue)
    {
        return toAjax(tCatalogueService.insertTCatalogue(tCatalogue));
    }

    /**
     * 修改目录
     */
    @Log(title = "目录", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改目录")
    public AjaxResult edit(@RequestBody TCatalogue tCatalogue)
    {
        return toAjax(tCatalogueService.updateTCatalogue(tCatalogue));
    }

    /**
     * 删除目录
     */
    @Log(title = "目录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cCatalogueIds}")
    @ApiOperation("删除目录")
    public AjaxResult remove(@PathVariable Long[] cCatalogueIds)
    {
        return toAjax(tCatalogueService.deleteTCatalogueByCCatalogueIds(cCatalogueIds));
    }
}
